<?php

/**
 * Created by PhpStorm.
 * Author: ls
 * Time: 2023/8/16 15:11
 * Desc:订单创建企业微信通知
 */
class Listener_Order_Created_Qywx extends Listener_Base
{


    public function handle($args)
    {
        $self       = new self();
        $self->args = $args;
        //判断队列是否开启,如果开启则把任务推送到队列
        if ($self->queue_status) {
            //推送到队列执行
            Queue::in('default', Listener_Order_Created_Qywx::class, $args);
        } else {
            $self->perform();
        }

    }

    public function perform()
    {
        $order = $this->args;
        switch ($order['need_confirm']) {
            case 2://支付前确认
                $type = St_NoticeCommon::PRODUCT_ORDER_UNPROCESSING_MSGTAG;
                break;
            case 1:
            case 0:
            default:
                $type = St_NoticeCommon::PRODUCT_ORDER_PROCESSING_MSGTAG;
                break;
        }
        //用户通知信息
        $result = St_QywxService::send_product_order_qywx($type, $order);
        St_Log::write('企业微信', array('type' => $type, 'ordersn' => $order['ordersn'], 'result' => $result), 'event/order_created/log');
    }

}